<template>
  <div class="app-container home">
    <el-row :gutter="20">
      <el-col :sm="24" :lg="24">
        <el-card style="font-size: 14px">
          <div slot="header"><span>工作台</span></div>
          <hr />
          <div class="first">
            <img :src="userStore.avatar" style="width: 50px; height: 50px; float:left; margin-right:10px; border-radius:50%" />
            <p style="white-space:nowrap; font-size:16px; margin-bottom:8px">{{ state.user.userName }}, {{ state.hello }}</p>
            <!-- <p style="font-size:12px;color:rgb(185, 181, 189);width: 300px;">今天是：{{ state.nowTime }}</p> -->
          </div>

        </el-card>
      </el-col>
    </el-row>
    <el-divider />
    <el-row :gutter="20">
      <el-col :span="12">
        <el-card shadow="always" style="padding-bottom: 20px;">
          <el-row :gutter="40" class="panel-group">
            <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
              <div class="card-panel" @click="handleGo('/procure/purchaseDocumentQuery')" v-hasPermi="['baseDate:warehouse:list']">
                <div class="card-panel-icon-wrapper icon-people">
                  <svg-icon icon-class="search" class-name="card-panel-icon"/>
                </div>
                <div class="card-panel-description">
                  <div class="card-panel-text">
                    采购
                  </div>
                  <div>
                    单据查询
                  </div>
                  <!-- <count-to :start-val="0" :end-val="warehouseList.length" :duration="3000" class="card-panel-num" /> -->
                </div>
              </div>
            </el-col>
            <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
              <div class="card-panel" @click="handleGo('/sales/salesDocumentQuery')" v-hasPermi="['baseDate:supplier:list']">
                <div class="card-panel-icon-wrapper icon-money">
                  <svg-icon icon-class="search" class-name="card-panel-icon" />
                </div>
                <div class="card-panel-description">
                  <div class="card-panel-text">
                    销售
                  </div>
                  <div>
                    单据查询
                  </div>
                  <!-- <count-to :start-val="0" :end-val="supplierList.length" :duration="2600" class="card-panel-num" /> -->
                </div>
              </div>
            </el-col>
            <el-col :xs="12" :sm="12" :lg="8">
              <div class="card-panel"  @click="handleGo('/inventory/InventoryDocumentQuery')" v-hasPermi="['baseDate:customer:list']">
                <div class="card-panel-icon-wrapper icon-message">
                  <svg-icon icon-class="search" class-name="card-panel-icon" />
                </div>
                <div class="card-panel-description">
                  <div class="card-panel-text">
                    库存
                  </div>
                  <div>
                    单据查询
                  </div>
                  <!-- <count-to :start-val="0" :end-val="customerList.length" :duration="3000" class="card-panel-num" /> -->
                </div>
              </div>
            </el-col>
            <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
              <div class="card-panel" @click="handleGo('/basedate/warehouse')" v-hasPermi="['baseDate:warehouse:list']">
                <div class="card-panel-icon-wrapper icon-people">
                  <svg-icon icon-class="table" class-name="card-panel-icon"/>
                </div>
                <div class="card-panel-description">
                  <div class="card-panel-text">
                    仓库
                  </div>
                  <!-- <count-to :start-val="0" :end-val="warehouseList.length" :duration="3000" class="card-panel-num" /> -->
                </div>
              </div>
            </el-col>
            <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
              <div class="card-panel" @click="handleGo('/basedate/supplier')" v-hasPermi="['baseDate:supplier:list']">
                <div class="card-panel-icon-wrapper icon-money">
                  <svg-icon icon-class="peoples" class-name="card-panel-icon" />
                </div>
                <div class="card-panel-description">
                  <div class="card-panel-text">
                    供应商
                  </div>
                  <!-- <count-to :start-val="0" :end-val="supplierList.length" :duration="2600" class="card-panel-num" /> -->
                </div>
              </div>
            </el-col>
            <el-col :xs="12" :sm="12" :lg="8">
              <div class="card-panel"  @click="handleGo('/basedate/customer')" v-hasPermi="['baseDate:customer:list']">
                <div class="card-panel-icon-wrapper icon-message">
                  <svg-icon icon-class="star" class-name="card-panel-icon" />
                </div>
                <div class="card-panel-description">
                  <div class="card-panel-text">
                    客户
                  </div>
                  <!-- <count-to :start-val="0" :end-val="customerList.length" :duration="3000" class="card-panel-num" /> -->
                </div>
              </div>
            </el-col>
            <el-col :xs="12" :sm="12" :lg="12">
              <div class="card-panel"  @click="handleGo('/basedate/product')" v-hasPermi="['baseDate:customer:list']">
                <div class="card-panel-icon-wrapper icon-message">
                  <svg-icon icon-class="date" class-name="card-panel-icon" />
                </div>
                <div class="card-panel-description">
                  <div class="card-panel-text">
                    货品资料
                  </div>
                  <!-- <count-to :start-val="0" :end-val="customerList.length" :duration="3000" class="card-panel-num" /> -->
                </div>
              </div>
            </el-col>
            <el-col :xs="12" :sm="12" :lg="12">
              <div class="card-panel"  @click="handleGo('/basedate/productType')" v-hasPermi="['baseDate:customer:list']">
                <div class="card-panel-icon-wrapper icon-message">
                  <svg-icon icon-class="tree" class-name="card-panel-icon" />
                </div>
                <div class="card-panel-description">
                  <div class="card-panel-text">
                    货品类型
                  </div>
                  <!-- <count-to :start-val="0" :end-val="customerList.length" :duration="3000" class="card-panel-num" /> -->
                </div>
              </div>
            </el-col>
          </el-row>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card shadow="always" style="padding-bottom: 20px; font-size: 14px;margin-bottom: 20px;">
          <div slot="header" ref="warn"><span>预警</span></div>
        <!-- <el-table v-loading="loading" :data="warnList">
            <el-table-column align="left" label="编号" prop="id" width="72"></el-table-column>
            <el-table-column align="left" label="物料" prop="itemName">
              <template v-slot="{ row }"><span style="color:red">{{ row.itemName }}</span></template>
            </el-table-column>
            <el-table-column align="left" label="编码" prop="itemNo"></el-table-column>
            <el-table-column align="left" label="仓库">
              <template v-slot="{ row }"><span v-if="row.warehouseName">{{ row.warehouseName }}</span><span
                  v-if="row.areaName">/{{ row.areaName }}</span></template>
            </el-table-column>
            <el-table-column align="left" label="当前库存">
              <template v-slot="{ row }"><span style="color:red;font-weight: bold;">{{ row.quantity }}</span></template>
            </el-table-column>
            <el-table-column align="left" label="库存下限" prop="saftyQuantity"></el-table-column>
          </el-table> -->
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup name="Index">
// import { ref } from 'vue';
import { useRouter } from 'vue-router';
import useUserStore from '@/store/modules/user';
import { getUserProfile } from "@/api/system/user";

const dates = ref(new Date())
const router = useRouter()
const version = ref('1.0.0')
const userStore = useUserStore()
const state = reactive({
  user: {},
  hello: {},
  nowTime: ''
});
const formatDate = () => {
  const year = date.value.getFullYear()
  const month = date.value.getMonth() + 1
  const day = date.value.getDate()
  return `${year}-${month}-${day}`
}

function goTarget(url) {
  window.open(url, '__blank')
};
function helloTimes() {
  let hh = new Date().getHours()
  if (0 < hh && hh < 12) {
    state.hello = '上午好'
  } else if (hh < 18) {
    state.hello = '下午好'
  } else {
    state.hello = '晚上好'
  }
};
function timeFormate(timeStamp) {
  let year = new Date(timeStamp).getFullYear()
  let month =
    new Date(timeStamp).getMonth() + 1 < 10
      ? '0' + (new Date(timeStamp).getMonth() + 1)
      : new Date(timeStamp).getMonth() + 1
  let date =
    new Date(timeStamp).getDate() < 10
      ? '0' + new Date(timeStamp).getDate()
      : new Date(timeStamp).getDate()
  let hh =
    new Date(timeStamp).getHours() < 10
      ? '0' + new Date(timeStamp).getHours()
      : new Date(timeStamp).getHours()
  let mm =
    new Date(timeStamp).getMinutes() < 10
      ? '0' + new Date(timeStamp).getMinutes()
      : new Date(timeStamp).getMinutes()
  let ss =
    new Date(timeStamp).getSeconds() < 10
      ? '0' + new Date(timeStamp).getSeconds()
      : new Date(timeStamp).getSeconds()
  let week = new Date(timeStamp).getDay()
  let weeks = ['日', '一', '二', '三', '四', '五', '六']
  let getWeek = '星期' + weeks[week]
  this.nowTime =
    year +
    '年' +
    month +
    '月' +
    date +
    '日' +
    ' ' +
    getWeek
}
function handleGo(path) {
  router.push(path)
};
function getUser() {
  getUserProfile().then(response => {
    state.user = response.data;
  });
};
function showTimes() {
  // date.value = new Date()
  // timeFormate(date);
};
getUser();
helloTimes();
showTimes();
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
.home-wrapper

  .li {
    float: left;
    width: 25%;
    font-size: 12px;
    color: rgb(185, 181, 189);
  }

  .da {
    float: left;
    width: 25%;
    font-size: 20px;
  }

  .first {
    float: left;
    margin-bottom: 20px;
  }

  .el-table .warning-row {
    background: rgb(39, 138, 230);
  }
  .panel-group {
    margin-top: 18px;

    .card-panel-col {
      margin-bottom: 10px;
    }

    .card-panel {
      height: 108px;
      cursor: pointer;
      font-size: 12px;
      position: relative;
      overflow: hidden;
      color: #666;
      background: #fff;
      box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
      border-color: rgba(0, 0, 0, .05);

      &:hover {
        .card-panel-icon-wrapper {
          color: #fff;
        }

        .icon-people {
          background: #40c9c6;
        }

        .icon-message {
          background: #36a3f7;
        }

        .icon-money {
          background: #f4516c;
        }
      }

      .icon-people {
        color: #40c9c6;
      }

      .icon-message {
        color: #36a3f7;
      }

      .icon-money {
        color: #f4516c;
      }

      .card-panel-icon-wrapper {
        float: left;
        margin: 14px 0 0 14px;
        padding: 16px;
        transition: all 0.38s ease-out;
        border-radius: 6px;
      }

      .card-panel-icon {
        float: left;
        font-size: 48px;
      }

      .card-panel-description {
        float: right;
        font-weight: bold;
        margin: 26px;
        margin-left: 0px;

        .card-panel-text {
          line-height: 18px;
          color: rgba(0, 0, 0, 0.45);
          font-size: 16px;
          margin-bottom: 12px;
        }

        .card-panel-num {
          font-size: 20px;
        }
      }
    }
  }

  @media (max-width:550px) {
    .card-panel-description {
      display: none;
    }

    .card-panel-icon-wrapper {
      float: none !important;
      width: 100%;
      height: 100%;
      margin: 0 !important;

      .svg-icon {
        display: block;
        margin: 14px auto !important;
        float: none !important;
      }
    }
  }
</style>

